<template>
  <a-layout id="layout">
    <LeftSide></LeftSide>
    <a-layout>
      <a-layout-header class="flex j-s" style="background: #fff; padding: 0">
        <a-icon
          class="trigger"
          :type="collapsed ? 'menu-unfold' : 'menu-fold'"
          @click="setCollapsed"
        />
        <a-dropdown style="float:right;margin-right:15px">
          <a class="ant-dropdown-link" @click="e => e.preventDefault()">
            管理员 <a-icon type="down" />
          </a>
          <a-menu slot="overlay">
            <a-menu-item>
              <a href="javascript:;">注册</a>
            </a-menu-item>
            <a-menu-item>
              <a href="javascript:;">修改密码</a>
            </a-menu-item>
            <a-menu-item>
              <router-link to="/">
              <a href="javascript:;">注销</a>
              </router-link>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </a-layout-header>
      <a-layout-content
        :style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
      >
        <router-view></router-view>
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>

<script>

import LeftSide from '@/components/LeftSide'
import { mapState, mapMutations } from 'vuex'

export default {
  components: {
    LeftSide
  },
  methods: {
    ...mapMutations(['setTitle', 'setCollapsed'])
  },
  computed: {
    ...mapState({
      title: state => state.menu.title,
      collapsed: state => state.menu.collapsed
    })
  },
  created () {
    this.setTitle(this.$route.meta.title)
  }
}
</script>

<style lang="scss" scoped>
#layout {
  height: 100vh;
}

#layout .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#layout .trigger:hover {
  color: #1890ff;
}

</style>
